package com.jin.config.MessageConfig;

public  class Message<T>
{

    public interface UnionSimpleView {}

    private boolean result;
    private String msg;
    private T obj;
    private Integer code;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    private Message(boolean result, String msg) {
        this.result = result;
        this.msg = msg;
    }

    public static <T> Message<T> success(String str){
        return new Message<T>(true,str==null?"操作成功":str);
    }

    public static <T> Message<T> fail(String str){
        return new Message<T>(false,str==null?"操作失败":str);
    }


    @SuppressWarnings("rawtypes")
	public Message add(T obj)
    {
        this.setObj(obj);
        return this;
    }

    public Message add(T obj,Integer code){
        this.setObj(obj);
        this.setCode(code);
        return this;
    }


    public boolean getResult()
    {
        return result;
    }

    public void setResult(boolean result)
    {
        this.result = result;
    }

    public String getMsg()
    {
        return msg;
    }

    public void setMsg(String msg)
    {
        this.msg = msg;
    }

    public T getObj()
    {
        return obj;
    }

    public void setObj(T obj)
    {
        this.obj= obj;
    }

}
